import 'dart:async';
import 'package:dio/dio.dart';
import 'package:dustbin_sort/model/news_model_entity.dart';


const HOME_URL = 'http://v.juhe.cn/toutiao/index?type=keji&key=823dbc24562cedc97a07e180d63bae07';

class HomeDao{
	static Future<NewsModelEntity> fetch() async{
		Response response = await Dio().get(HOME_URL);
		if(response.statusCode == 200){
				return NewsModelEntity().fromJson(response.data);
			}else{
			throw Exception("fail to load data from api");
		}
	}
}